﻿using System.IO;
using System.Xml.Serialization;

namespace T4UtilityBelt.LightSwitch.FileModels
{
    public static class LightSwitchModel
    {
        public static ModelFragment Load(string fileName)
        {
            XmlSerializer xs = new XmlSerializer(typeof(ModelFragment));

            using (FileStream sr = File.OpenRead(fileName))
            {
                return xs.Deserialize(sr) as ModelFragment;
            }
        }

        //public static Model LoadModel(string fileName)
        //{
        //    XmlSerializer xs = new XmlSerializer(typeof(ModelFragment));

        //    using (FileStream sr = File.OpenRead(fileName))
        //    {
        //        ModelFragment fragment = xs.Deserialize(sr) as ModelFragment;
        //        if (fragment != null)
        //        {
        //            return fragment.ToModel();
        //        }
        //    }
        //    return null;
        //}
    }
}